/*
 *  (C) 2009 Igor Vdovichenko

 *  File: ConnectionInfo.java
 *
 *  Author: Igor Vdovichenko
 *  Created on 22.05.2009, 18:36:26
 *
 */

package com.vin.scriptutils.utils.ssh;

/**
 *
 * @author ivdovichenko
 */
public class ConnectionInfo {

    private String hostAddress;
    private String password;
    private String username;

    public ConnectionInfo(){}

    public ConnectionInfo(final ConnectionInfo ci){
        setHostAddress(ci.getHostAddress());
        setUsername(ci.getUsername());
        setPassword(ci.getPassword());
    }

    public String getHostAddress() {
        return hostAddress;
    }

    public void setHostAddress(String hostAddress) {
        this.hostAddress = hostAddress;
    }

    /**
     * Get the username.
     */
    public final String getUsername() {
        return username;
    }

    /**
     * Set the username.
     * @param username
     */
    public final void setUsername(String username) {
        if (username == null) {
            throw new IllegalArgumentException("username can't be null");
        }
        this.username = username;
    }

    /**
     * Set the password.
     *
     * @param password
     * @since 1.0.0
     */
    public final void setPassword(String password) {
        if (password == null) {
            password = "";
        }
        this.password = password;
    }

    /**
     * Get the password.
     */
    public final String getPassword() {
        return this.password;
    }


    public ConnectionInfo HostAddress(String hostAddress) {
        setHostAddress(hostAddress);
        return this;
    }

    public ConnectionInfo Username(String username) {
        setUsername(username);
        return this;
    }

    public ConnectionInfo Password(String password) {
        setPassword(password);
        return this;
    }

}
